package com.gem.talkbase.activity;

import com.gem.talkbase.R;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ProgressBar;
import android.widget.TextView;

public class Setinformation_aboutus extends Activity {
	private int[] data = new int[100];  
	int hasData = 0;  
	//记录ProgressBar的完成进度  
	int status = 0;
	ProgressBar progressBar;

	final Handler mHandler = new Handler(){  
		@Override  
		public void handleMessage(Message msg)  
		{  
			//表明消息是由该程序发送的。  
			if (msg.what == 0x111)  
			{  
				progressBar.setProgress(status); 
				textView10.setText(status+"%");

			}  

			if(status==99){
				progressBar.setVisibility(View.GONE);
				textView10.setVisibility(View.GONE);
			}
		}  
	};

	TextView textView5,textView9,textView10;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.setinformation_aboutus);
		textView9 = (TextView)findViewById(R.id.l9); 
		textView9.setText(Html.fromHtml("<u>"+"官网 | 服务条款"+"</u>"));




		progressBar = (ProgressBar) findViewById(R.id.progressBar); 
		progressBar.setVisibility(View.GONE); 
		textView10 = (TextView)findViewById(R.id.l10); 
		textView10.setVisibility(View.GONE); 

		textView5 = (TextView)findViewById(R.id.l5); 
		textView5.setOnClickListener(new OnClickListener() {  

			@Override  
			public void onClick(View arg0) {  
				// TODO Auto-generated method stub  
				hasData = 0;  
				status = 0; 
				progressBar.setVisibility(View.VISIBLE);
				textView10.setVisibility(View.VISIBLE);

				//启动线程来执行任务  
				new Thread()  
				{  
					public void run()  
					{  
						while (status < 100)  
						{  
							// 获取耗时操作的完成百分比  
							status = doWork();  
							// 发送消息到Handler  
							Message m = new Message();  
							m.what = 0x111;  
							// 发送消息  
							Setinformation_aboutus.this.mHandler.sendMessage(m);  
						}  
					}  
				}.start();  


			}  
		});  

	}


	public int doWork()  
	{  
		//为数组元素赋值  
		data[hasData++] = (int)(Math.random() * 100);  
		try  
		{  
			Thread.sleep(100);  
		}catch (InterruptedException e)  
		{  
			e.printStackTrace();  
		}  
		return hasData;  

	}





}
